<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of myInflector
 *
 * @author Ana Dalva Oliveira
 */
class MyInflector extends Inflector {

    public static function acentos($palavra) {
        $espacamentos = array(' ', '_');
        foreach ($espacamentos as $espacamento) {
            if (strpos($palavra, $espacamento) !== false) {
                $palavra = explode($espacamento, $palavra);
                $saida = '';
                foreach ($palavra as $pedaco) {
                    $saida .= MyInflector::acentos($pedaco) . $espacamento;
                }
                return rtrim($saida, $espacamento);
            }
        }
        if (preg_match('/(.*)cao$/', $palavra, $matches)) {
            return $matches[1] . 'ção';
        }
        if (preg_match('/(.*)ao(s)?$/', $palavra, $matches)) {
            return $matches[1] . 'ão' . (isset($matches[2]) ? $matches[2] : '');
        }
        if (preg_match('/(.*)coes$/', $palavra, $matches)) {
            return $matches[1] . 'ções';
        }
        if (preg_match('/(.*)oes$/', $palavra, $matches)) {
            return $matches[1] . 'ões';
        }
        if (preg_match('/(.*)aes$/', $palavra, $matches)) {
            return $matches[1] . 'ães';
        }
        return $palavra;
    }

    //put your code here
}
